]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
ScreenShield: wake up the screen when new notifications appear
authorGiovanni Campagna <gcampagna@src.gnome.org>
Sun, 14 Jul 2013 14:20:49 +0000 (16:20 +0200)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Wed, 7 Aug 2013 08:33:15 +0000 (10:33 +0200)
This way the user is immediately notified when something happens.

https://bugzilla.gnome.org/show_bug.cgi?id=703084

js/ui/screenShield.js
src/shell-util.c
src/shell-util.h

index f85871f7a8beda1f53816e62bbf4d863e0d9090c..5e7693cd0d4946271534b3fb284a7982a575b68f 100644 (file)
@@ -305,7 +305,9 @@ const NotificationsBox = new Lang.Class({
                                },
                                onCompleteScope: this
                              });
+
             this._updateVisibility();
+            Shell.util_wake_up_screen();
         }
     },
 
@@ -328,7 +330,10 @@ const NotificationsBox = new Lang.Class({
 
         obj.sourceBox.visible = obj.visible &&
             (source.unseenCount > (obj.musicNotification ? 1 : 0));
+
         this._updateVisibility();
+        if (obj.sourceBox.visible)
+            Shell.util_wake_up_screen();
     },
 
     _visibleChanged: function(source, obj) {
@@ -342,6 +347,8 @@ const NotificationsBox = new Lang.Class({
             source.unseenCount > (obj.musicNotification ? 1 : 0);
 
         this._updateVisibility();
+        if (obj.sourceBox.visible)
+            Shell.util_wake_up_screen();
     },
 
     _detailedChanged: function(source, obj) {
index 0f19efcf34af96d589ff6be6e6aaa3ef95d96d43..84adad9aaaed73eceb44c1bc7b59cab2ef0cee83 100644 (file)
@@ -9,6 +9,8 @@
 #include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gdk/gdkx.h>
+#include <X11/extensions/XTest.h>
 
 #ifdef HAVE__NL_TIME_FIRST_WEEKDAY
 #include <langinfo.h>
@@ -402,3 +404,30 @@ shell_util_create_pixbuf_from_data (const guchar      *data,
                                    bits_per_sample, width, height, rowstride,
                                    (GdkPixbufDestroyNotify) g_free, NULL);
 }
+
+/**
+ * shell_util_wake_up_screen:
+ *
+ * Send a fake key event, resetting the IDLETIME counter and
+ * causing gnome-settings-daemon to wake up the screen.
+ */
+/* Shamelessly taken from gnome-settings-daemon/plugins/power/gpm-common.c */
+void
+shell_util_wake_up_screen (void)
+{
+  static gboolean inited = FALSE;
+  static KeyCode keycode1, keycode2;
+  static gboolean first_keycode = FALSE;
+
+  if (inited == FALSE) {
+    keycode1 = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), GDK_KEY_Alt_L);
+    keycode2 = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), GDK_KEY_Alt_R);
+  }
+
+  gdk_error_trap_push ();
+  /* send a left or right alt key; first press, then release */
+  XTestFakeKeyEvent (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), first_keycode ? keycode1 : keycode2, True, CurrentTime);
+  XTestFakeKeyEvent (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), first_keycode ? keycode1 : keycode2, False, CurrentTime);
+  first_keycode = !first_keycode;
+  gdk_error_trap_pop_ignored ();
+}
index 6fc2a5db0387642b953dbd3c997b1f34440ba178..2d462c1c50dc12ceb9798da8cf7d464000468f50 100644 (file)
@@ -44,6 +44,8 @@ GdkPixbuf *shell_util_create_pixbuf_from_data (const guchar      *data,
                                                int                height,
                                                int                rowstride);
 
+void    shell_util_wake_up_screen             (void);
+
 G_END_DECLS
 
 #endif /* __SHELL_UTIL_H__ */